<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>评分汇总</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .mbox {
        padding: 8px
    }

    .item img {
        height: 40px;
    }

    .btn {
        height: 30px;
    }

    .btn button {
        float: right;
    }

    .information {
        background: #e8f4fc;
        height: 30px;
        line-height: 30px;
    }
    .layui-form-label{
        width: 77px;
    }

</style>
<body>
<div class="mbox">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">评分汇总</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="btn">
        <button type="button" class="layui-btn layui-btn-sm" style="background: #2b7fe0"><i
                class="layui-icon layui-icon-upload-drag" style="background: #2b7fe0"></i>导出Excel
        </button>
    </div>

    <div>
        <table class="layui-hide" id="testlook" lay-filter="testlook"></table>
    </div>


</div>
</body>
</html>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-sm" lay-event="scoreSum">进入评分汇总</a>
</script>

<script>
    var table;
    $(function(){
        layui.use(['table'], function () {
            table = layui.table;

            //渲染表格
            table.render({
                elem: '#testlook'
                ,url:'/RpmResearchScore/findScoreConfluence'
                ,cellMinWidth: 80
                ,cols: [[
                    {type: 'numbers', title: '序号', align: 'center',width:200}
                    ,{field:'planName',  title: '计划名称',align:'center'}
                    ,{fixed: '', title:'操作', toolbar: '#barDemo',align: 'center'}
                ]]
                ,parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code": 0 , //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.total, //解析数据长度
                        "data": res.object //解析数据列表
                    };
                }
            });

            // 监听行工具事件
            table.on('tool(testlook)', function(obj){
                var data = obj.data;
                if(obj.event === 'scoreSum'){
                    layer.open({
                        type: 1,
                        title: '评分汇总',
                        btn: ['返回'],
                        area: ['100%', '100%'],
                        content:'<div style="margin: 10px"><div class="layui-form">\n' +
                            '        <table class="layui-table">\n' +
                            '            <thead>\n' +
                            '            <tr>\n' +
                            '                <th>计划名称</th>\n' +
                            '                <th>项目名称</th>\n' +
                            '                <th>专家1 评分</th>\n' +
                            '                <th>意见</th>\n' +
                            '                <th>专家2 评分</th>\n' +
                            '                <th>意见</th>\n' +
                            '                <th>专家3 评分</th>\n' +
                            '                <th>意见</th>\n' +
                            '                <th>专家4 评分</th>\n' +
                            '                <th>意见</th>\n' +
                            '                <th>平均分</th>\n' +
                            '                <th>状态</th>\n' +
                            '                <th>操作</th>\n' +
                            '            </tr>\n' +
                            '            </thead>\n' +
                            '            <tbody class="cont">\n' +
                            '            </tbody>\n' +
                            '        </table>\n' +
                            '    </div></div>',
                        success:function(){
                            var strs = ''
                            strs = '<tr>' +
                                '<td>'+empty(data.planName)+'</td>\n' +
                                '<td>'+empty(data.rpmTopicList[0].topicName)+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[0]){
                                        return scoreWithBLOBsList[0].rsScore;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[0]){
                                        return scoreWithBLOBsList[0].remarks;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[1]){
                                        return scoreWithBLOBsList[1].rsScore;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){456
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[1]){
                                        return scoreWithBLOBsList[1].remarks;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[2]){
                                        return scoreWithBLOBsList[2].rsScore;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[2]){
                                        return scoreWithBLOBsList[2].remarks;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[3]){
                                        return scoreWithBLOBsList[3].rsScore;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+function (){
                                    var scoreWithBLOBsList = data.scoreWithBLOBsList;
                                    if(scoreWithBLOBsList.length > 0 && scoreWithBLOBsList[3]){
                                        return scoreWithBLOBsList[3].remarks;
                                    }else{
                                        return ''
                                    }
                                }()+'</td>\n' +
                                '<td>'+empty(data.avg)+'</td>\n' +
                                '<td>'+empty(data.scoreStatus)+'</td>\n' +
                                '<td>' +
                                '<button type="button" class="layui-btn layui-btn-normal layui-btn-xs btnlook">查看</button>' +
                                '</td>\n'+
                                '</tr>'
                            $('.cont').html(strs)

                            $('.btnlook').click(function(){
                                Summary(data)
                            })
                        }
                    })
                }
            });

        })
    });
    function Summary(data){
        layer.open({
            type: 1,
            title: '查看',
            btn: ['返回'],
            shade: 0.5,
            maxmin: true, //开启最大化最小化按钮
            area: ['40%', '40%'],
            offset: '200px',
            content: '<div style="padding: 20px; background-color: #F2F2F2;" id="uploadmsg">' +
                '</div>'
            , success: function (res) {
                var score = data.scoreWithBLOBsList;

                for (var i = 0; i < score.length; i++) {
                    var rsScore = score[i].rsScore;
                    var eName = score[i].eName;
                    var ephone = score[i].ephone;
                    var str = '<div class="layui-card">\n' +
                        '  <div class="layui-card-header"> 专家' +
                        (i+1) + '-' + eName + ephone + '-' +
                        function () {
                            if (rsScore!=undefined && rsScore != '' ){
                                return '已完成';
                            }
                            return '未完成';
                        } () +
                        '</div>\n';
                    $('#uploadmsg').append(str);
                }
            }
        });

    }

    //判断返回是否为空
    function empty(esName) {
        if(esName !=undefined){
            return esName
        }else{
            return ''
        }
    }

</script>
